<?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>
<?php
/**http://localhost:8983/solr/admin/ping
 * @see Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard
 */
?>
<script type="text/javascript">
    function testConnection() {
        var elem = $('<?php echo $this->getHtmlId() ?>');

        params = {
            host:       $('catalog_search_solr_server_hostname').value,
            port:       $('catalog_search_solr_server_port').value,
            path:       $('catalog_search_solr_server_path').value,
            login:      $('catalog_search_solr_server_username').value,
            password:   $('catalog_search_solr_server_password').value,
            timeout:    $('catalog_search_solr_server_timeout').value
        };

        new Ajax.Request('<?php echo $this->getAjaxUrl() ?>', {
            parameters: params,
            onSuccess: function(response) {
                result = '<?php echo Mage::helper('core')->jsQuoteEscape($this->__('Connection failed! Test again?')) ?>';
                try {
                    response = response.responseText;
                    if (response == 1) {
                        result = '<?php echo Mage::helper('core')->jsQuoteEscape($this->__('Successful! Test again?')) ?>';
                        elem.removeClassName('fail').addClassName('success')
                    } else {
                        elem.removeClassName('success').addClassName('fail')
                    }
                } catch (e) {
                    elem.removeClassName('success').addClassName('fail')
                }
                $('connection_test_result').update(result);
            }
        });
    }
</script>
<button onclick="javascript:testConnection(); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>">
    <span><span><span id="connection_test_result"><?php echo $this->escapeHtml($this->getButtonLabel()) ?></span></span></span>
</button>
